const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('sp_goods', {
    goods_id: {
      autoIncrement: true,
      type: DataTypes.MEDIUMINT.UNSIGNED,
      allowNull: false,
      primaryKey: true,
      comment: "主键id"
    },
    goods_name: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: "商品名称",
      unique: "goods_name"
    },
    goods_price: {
      type: DataTypes.DECIMAL(10,2),
      allowNull: false,
      defaultValue: 0.00,
      comment: "商品价格"
    },
    goods_number: {
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: false,
      defaultValue: 0,
      comment: "商品数量"
    },
    goods_weight: {
      type: DataTypes.SMALLINT.UNSIGNED,
      allowNull: false,
      defaultValue: 0,
      comment: "商品重量"
    },
    cat_id: {
      type: DataTypes.SMALLINT.UNSIGNED,
      allowNull: false,
      defaultValue: 0,
      comment: "类型id"
    },
    goods_introduce: {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: "商品详情介绍"
    },
    goods_big_logo: {
      type: DataTypes.CHAR(128),
      allowNull: false,
      defaultValue: "",
      comment: "图片logo大图"
    },
    goods_small_logo: {
      type: DataTypes.CHAR(128),
      allowNull: false,
      defaultValue: "",
      comment: "图片logo小图"
    },
    is_del: {
      type: DataTypes.ENUM('0','1'),
      allowNull: false,
      defaultValue: "0",
      comment: "0:正常  1:删除"
    },
    add_time: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "添加商品时间"
    },
    upd_time: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "修改商品时间"
    },
    delete_time: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "软删除标志字段"
    },
    cat_one_id: {
      type: DataTypes.SMALLINT,
      allowNull: true,
      defaultValue: 0,
      comment: "一级分类id"
    },
    cat_two_id: {
      type: DataTypes.SMALLINT,
      allowNull: true,
      defaultValue: 0,
      comment: "二级分类id"
    },
    cat_three_id: {
      type: DataTypes.SMALLINT,
      allowNull: true,
      defaultValue: 0,
      comment: "三级分类id"
    },
    hot_mumber: {
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: true,
      defaultValue: 0,
      comment: "热卖数量"
    },
    is_promote: {
      type: DataTypes.SMALLINT,
      allowNull: true,
      defaultValue: 0,
      comment: "是否促销"
    },
    goods_state: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "商品状态 0: 未通过 1: 审核中 2: 已审核"
    }
  }, {
    sequelize,
    tableName: 'sp_goods',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "goods_id" },
        ]
      },
      {
        name: "goods_name",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "goods_name" },
        ]
      },
      {
        name: "goods_price",
        using: "BTREE",
        fields: [
          { name: "goods_price" },
        ]
      },
      {
        name: "add_time",
        using: "BTREE",
        fields: [
          { name: "add_time" },
        ]
      },
      {
        name: "goods_name_2",
        using: "BTREE",
        fields: [
          { name: "goods_name" },
        ]
      },
    ]
  });
};
